<%@ Page Language="C#" AutoEventWireup="true" CodeFile="city_names.aspx.cs" Inherits="city_names" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="code,lang"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="code" HeaderText="code" ReadOnly="True" SortExpression="code" />
                <asp:BoundField DataField="lang" HeaderText="lang" ReadOnly="True" SortExpression="lang" />
                <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
            </Columns>
        </asp:GridView>
        <br />
        <br />
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="code,lang" DataSourceID="SqlDataSource1"
            DefaultMode="Insert">
            <EditItemTemplate>
                code:
                <asp:Label ID="codeLabel1" runat="server" Text='<%# Eval("code") %>'></asp:Label><br />
                lang:
                <asp:Label ID="langLabel1" runat="server" Text='<%# Eval("lang") %>'></asp:Label><br />
                name:
                <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text="Update">
                </asp:LinkButton>
                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </EditItemTemplate>
            <InsertItemTemplate>
                code:
                <asp:TextBox ID="codeTextBox" runat="server" Text='<%# Bind("code") %>'>
                </asp:TextBox><br />
                lang:
                <asp:TextBox ID="langTextBox" runat="server" Text='<%# Bind("lang") %>'>
                </asp:TextBox><br />
                name:
                <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Insert">
                </asp:LinkButton>
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="Cancel">
                </asp:LinkButton>
            </InsertItemTemplate>
            <ItemTemplate>
                code:
                <asp:Label ID="codeLabel" runat="server" Text='<%# Eval("code") %>'></asp:Label><br />
                lang:
                <asp:Label ID="langLabel" runat="server" Text='<%# Eval("lang") %>'></asp:Label><br />
                name:
                <asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>'></asp:Label><br />
                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="Edit">
                </asp:LinkButton>
                <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                    Text="Delete">
                </asp:LinkButton>
                <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                    Text="New">
                </asp:LinkButton>
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SparrowDB %>"
            DeleteCommand="DELETE FROM [city_names] WHERE [code] = @code AND [lang] = @lang"
            InsertCommand="INSERT INTO [city_names] ([code], [lang], [name]) VALUES (@code, @lang, @name)"
            SelectCommand="SELECT * FROM [city_names]" UpdateCommand="UPDATE [city_names] SET [name] = @name WHERE [code] = @code AND [lang] = @lang">
            <DeleteParameters>
                <asp:Parameter Name="code" Type="String" />
                <asp:Parameter Name="lang" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="name" Type="String" />
                <asp:Parameter Name="code" Type="String" />
                <asp:Parameter Name="lang" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="code" Type="String" />
                <asp:Parameter Name="lang" Type="String" />
                <asp:Parameter Name="name" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
